package com.colorsstudio.defence 
{
	import com.colorsstudio.defence.ConstantValues.Constants;
	import com.colorsstudio.defence.ConstantValues.Stats;
	import com.colorsstudio.defence.Levels.AchievementsScene;
	import com.colorsstudio.defence.Levels.gameScene1;
	import com.colorsstudio.defence.Levels.levelLogo;
	import com.colorsstudio.defence.Levels.SettingScene;
	import com.colorsstudio.defence.Levels.startScreen;
	import com.colorsstudio.defence.sounds.SoundLibrary;
	import com.colorsstudio.defence.sounds.SoundManager;
	import com.colorsstudio.defence.test.DataStructure;
	import com.colorsstudio.defence.test.Fsm;
	import flash.desktop.ClipboardTransferMode;
	import flash.display.MovieClip;
	import flash.net.SharedObject;
	import flash.utils.Dictionary;
	import idv.cjcat.fenofsm.events.StateEvent;
	import idv.cjcat.fenofsm.FSMachine;
	import idv.cjcat.fenofsm.State;
	import idv.cjcat.signals.Signal;

	/**
	 * ...
	 * @author wuzhida
	 */
	public class GameMain extends MovieClip 
	{
		//添加声音的测试.
		public var SOUND_TEST_SOUND:String = "TestSound";
		public var soundManager:SoundManager = new SoundManager();
		
		public var state:State;
		public var levels:Dictionary = Constants.levels;
		
		public function GameMain() 
		{
			////trace("----------------------------GameStart----------------------------");
			//显示fps和效率
			this.stage.addChild(new Stats());
			Constants.main = this;
			state = Constants.fsm.initState;
			weNeedToSetUpAllTheStateBeforePlaying();
			
			//添加声音并播放它.
			soundManager.addSound(SOUND_TEST_SOUND, new SoundLibrary.TestSound);
			//soundManager.playSound(SOUND_TEST_SOUND, true, int.MAX_VALUE);
			
			
			Constants.fsm.input("toLogo");
		}		
		
		public function weNeedToSetUpAllTheStateBeforePlaying():void 
		{
			levels["levelLogo"] = new levelLogo();
			levels["startScreen"] = new startScreen();
			levels["settingScreen"] = new SettingScene();
			levels["achievementsScreen"] = new AchievementsScene();
			levels["gameScene1"] = new gameScene1();
		}
	}
}